package top.ranzhang.mapper;

import org.apache.ibatis.annotations.*;
import top.ranzhang.bean.entity.Enrollments;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.List;


@Mapper
public interface EnrollmentsMapper extends BaseMapper<Enrollments> {

    @Select("SELECT * FROM enrollments WHERE enrollment_id = #{id}")
    Enrollments selectById(Long id);

    @Select("SELECT * FROM enrollments")
    List<Enrollments> selectAll();

    @Insert("INSERT INTO enrollments(student_id, course_id, enrollment_date, status, " +
            "payment_status, fee_amount) VALUES (#{studentId}, #{courseId}, #{enrollmentDate}, " +
            "#{status}, #{paymentStatus}, #{feeAmount})")
    void MInsert(Enrollments enrollment);

    @Update("UPDATE enrollments SET student_id=#{studentId}, course_id=#{courseId}, " +
            "enrollment_date=#{enrollmentDate}, status=#{status}, payment_status=#{paymentStatus}, " +
            "fee_amount=#{feeAmount} WHERE enrollment_id=#{enrollmentId}")
    void update(Enrollments enrollment);

    @Delete("DELETE FROM enrollments WHERE enrollment_id = #{id}")
    void delete(Long id);
}
